package com.thinkcube.edutainment.fragment;

import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.thinkcube.edutainment.R;

public class FollowCourseFragment extends Fragment {
	
	
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
		View view=inflater.inflate(R.layout.follow_course_main,container,false);
		/*add FollowCourseLessonBar fragment*/
		
		addLessonBar();
		addcourseContent();
	    
		return view;
	}
	
	
	
	private void addLessonBar()
	{
		
		FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
	    FollowCourseLessonBar lessonsBar=new FollowCourseLessonBar_();
	    Bundle bunlde=new Bundle();
	    if(getArguments().containsKey("pos"))
	    {
	    	bunlde.putInt("pos",getArguments().getInt("pos"));
	    	lessonsBar.setArguments(bunlde);
	    }
	
	    if (getArguments().containsKey("course")) {
	    	bunlde.putParcelable("course",getArguments().getParcelable("course"));


		}
	    
		fragmentTransaction.add(R.id.follow_course_lesson_bar, lessonsBar);
		
		fragmentTransaction.commit();
	}
	
	private void addcourseContent()
	{
		FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
	    FollowCoureseDetail lessonLontent=new FollowCoureseDetail_();
	
	    Bundle bundle = new Bundle();
		if(getArguments().containsKey("lessonContents"))
		{
			bundle.putParcelable("lessonContents", getArguments().getParcelable("lessonContents"));
		}
		lessonLontent.setArguments(bundle);
		fragmentTransaction.replace(R.id.lesson_content, lessonLontent);
		//fragmentTransaction.addToBackStack(null);
		fragmentTransaction.commit();
	}

}
